home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / oleo-1_4.lha / oleo-1.4 / args.h < prev    next >
C/C++ Source or Header  |  1993-03-25  |  5KB  |  156 lines

  1. #ifndef ARGSH
  2. #define ARGSH
  3.  
  4. /*    Copyright (C) 1993 Free Software Foundation, Inc.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this software; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19. /*  t. lord    Wed Jan 27 15:46:24 1993    */
  20.  
  21.  
  22.  
  23.  
  24. /* Interacting with command arguments. */
  25.  
  26. /* See find_stub. */
  27. enum command_arg_representation
  28. {
  29.   cmd_char  = 'c',
  30.   cmd_float = 'd',
  31.   cmd_file  = 'f',
  32.   cmd_int   = 'i',
  33.   cmd_key   = 'k',
  34.   cmd_range = 'r',
  35.   cmd_string = 's',
  36.   cmd_none  = '0'
  37. };
  38.  
  39. struct command_arg;
  40.  
  41. /* See comments in arg.c: */
  42.  
  43. #ifdef __STDC__
  44. typedef char * (*arg_verifier) (char ** end_out, struct command_arg *);
  45. typedef void (*arg_destroyer) (struct command_arg *);
  46. #else
  47. typedef char * (*arg_verifier) ();
  48. typedef void (*arg_destroyer) ();
  49. #endif
  50.  
  51. /* For every kind of prompt allowed in a FUNC_ARGS string, 
  52.  * there exists a prompt_style that describes how that
  53.  * kind of argument should be editted/passed:
  54.  */
  55.  
  56. struct prompt_style
  57. {
  58.   arg_verifier verify;
  59.   arg_destroyer destroy;
  60.   enum command_arg_representation representation;
  61.   char * keymap;
  62. };
  63.  
  64.  
  65.  
  66. #ifdef __STDC__
  67. extern char * char_verify (char ** end, struct command_arg * arg);
  68. extern char * symbol_verify (char ** end, struct command_arg * arg);
  69. extern char * word_verify (char ** end, struct command_arg * arg);
  70. extern void symbol_destroy (struct command_arg * arg);
  71. extern char * command_verify (char ** end, struct command_arg * arg);
  72. extern char * read_file_verify (char ** end, struct command_arg * arg);
  73. extern void read_file_destroy (struct command_arg * arg);
  74. extern char * write_file_verify (char ** end, struct command_arg * arg);
  75. extern void write_file_destroy (struct command_arg * arg);
  76. extern char * keyseq_verify (char ** end, struct command_arg * arg);
  77. extern char * keymap_verify (char ** end, struct command_arg * arg);
  78. extern char * number_verify (char ** end, struct command_arg * arg);
  79. extern char * double_verify (char ** end, struct command_arg * arg);
  80. extern char * range_verify (char ** end, struct command_arg * arg);
  81. extern char * string_verify (char ** end, struct command_arg * arg);
  82. extern char * yes_verify (char ** end, struct command_arg * arg);
  83. extern char * incremental_cmd_verify (char ** end, struct command_arg * arg);
  84. extern char * menu_verify (char ** end, struct command_arg * arg);
  85. extern char * format_verify (char ** end, struct command_arg * arg);
  86. extern char * noop_verify (char ** end, struct command_arg * arg);
  87.  
  88. #else
  89. extern char * char_verify ();
  90. extern char * symbol_verify ();
  91. extern char * word_verify ();
  92. extern void symbol_destroy ();
  93. extern char * command_verify ();
  94. extern char * read_file_verify ();
  95. extern void read_file_destroy ();
  96. extern char * write_file_verify ();
  97. extern void write_file_destroy ();
  98. extern char * keyseq_verify ();
  99. extern char * keymap_verify ();
  100. extern char * number_verify ();
  101. extern char * double_verify ();
  102. extern char * range_verify ();
  103. extern char * string_verify ();
  104. extern char * yes_verify ();
  105. extern char * incremental_cmd_verify ();
  106. extern char * menu_verify ();
  107. extern char * format_verify ();
  108. extern char * noop_verify ();
  109.  
  110. #endif
  111.  
  112. #ifdef DEFINE_STYLES
  113. #define DEFSTYLE(NAME,VER,DEST,REP,KEYMAP) \
  114. struct prompt_style NAME = \
  115. { \
  116.   VER, \
  117.   DEST, \
  118.   REP, \
  119.   KEYMAP \
  120. }
  121. #else
  122. #define DEFSTYLE(NAME,VER,DEST,REP,KEYMAP) extern struct prompt_style NAME
  123. #endif
  124.  
  125. DEFSTYLE(char_style, char_verify, 0, cmd_int, "read-char");
  126. DEFSTYLE(double_style, double_verify, 0, cmd_float, "read-float");
  127. DEFSTYLE(menu_style, menu_verify, 0, cmd_int, "read-menu");
  128. DEFSTYLE(format_style, format_verify, 0, cmd_int, "read-format");
  129. DEFSTYLE(symbol_style,
  130.      symbol_verify, symbol_destroy, cmd_string, "read-symbol");
  131. DEFSTYLE(word_style,
  132.      word_verify, symbol_destroy, cmd_string, "read-word");
  133. DEFSTYLE(command_style,
  134.      command_verify, symbol_destroy, cmd_string, "read-symbol");
  135. DEFSTYLE(read_file_style,
  136.      read_file_verify, read_file_destroy, cmd_file, "read-filename");
  137. DEFSTYLE(write_file_style,
  138.      write_file_verify, write_file_destroy, cmd_file, "read-filename");
  139. DEFSTYLE(keyseq_style, keyseq_verify, 0, cmd_key, "read-keyseq");
  140. DEFSTYLE(keymap_style,
  141.      keymap_verify, symbol_destroy, cmd_string, "read-symbol"); 
  142. DEFSTYLE(number_style, number_verify, 0, cmd_int, "read-integer");
  143. DEFSTYLE(range_style, range_verify, 0, cmd_range, "read-range");
  144. DEFSTYLE(formula_style, string_verify, 0, cmd_string, "read-formula");
  145. DEFSTYLE(string_style, string_verify, 0, cmd_string, "read-string");
  146. DEFSTYLE(file_name_style, string_verify, 0, cmd_string, "read-filename");
  147. DEFSTYLE(yes_style, yes_verify, 0, cmd_none, "read-string");
  148. DEFSTYLE(int_constant_style, 0, 0, cmd_int, 0);
  149. DEFSTYLE(range_constant_style, 0, 0, cmd_range, 0);
  150. DEFSTYLE(inc_cmd_style, incremental_cmd_verify, 0, cmd_none, "direction");
  151. DEFSTYLE(mode_style, noop_verify, 0, cmd_none, 0);
  152.  
  153. #endif  /* ARGSH */
  154.  
  155.  
  156.